package com.camtc.camcenter.dao.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.List;

/**
 * 云用户权限
 *
 * @author
 * @date
 */

@Data
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "cloud_permission")
@ToString
public class CloudPermission extends BaseEntity{

    @Id
    @GenericGenerator(name = "idGenerator", strategy = "uuid")
    @GeneratedValue(generator = "idGenerator")
    @Column(length = 64)
    private String id;

    @Column(name = "permission_name", length = 50)
    private String permissionName;

    @Column(name = "permission_code", length = 50)
    private String permissionCode;

    @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinTable(name = "cloud_role_permission", joinColumns = { @JoinColumn(name = "permission_id") }, inverseJoinColumns = {
            @JoinColumn(name = "role_id") })
    private List<CloudRole> roles;

}
